package com.gzcsqic.excelapp.service;

import com.gzcsqic.excelapp.dao.RecordMapper;
import com.gzcsqic.excelapp.entity.Record;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class RecordService {

    @Resource
    private RecordMapper recordMapper;

    public Map<String,Object> getList(Record record,int pageNo,int size){
        List<Record> records = recordMapper.selectList(record.getCompany(), (pageNo - 1) * size, size);
        int count = recordMapper.selectListCount(record);
        Map<String,Object> data = new HashMap<>();
        data.put("count",count);
        data.put("list",records);
        return data;
    }

    public Record addRecord(Record record){
        int i = recordMapper.insertSelective(record);
        return record;
    }

    public Record checkRecordExisted(Record record){
        return recordMapper.selectByCompany(record);
    }

}
